Repository navigation
audio: ffmpeg_dec: add ALAC decoder and FLAC/ALAC encoder support - #11427
Merged
Merged
Conversation
lgirdwood
force-pushed
the
topic/ffmpeg-lossless
branch
2 times, most recently
from
November 11, 2026 00:00
2a735e9 to
e3da217
Compare
Contributor
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
9 open issues
Thesedrules/FLAC_MAX_BLOCKSIZE/1152/greplaces the macro name everywhere, which can break… · Newcd->in_bufis used for header sniffing (memcmp/alac_read_be32) without first… · New Whenprev_len == 0, the code passesindirectly to libavcodec (pkt_data = in) without… · Newffmpeg_dec_pcm_to_frame()return value is ignored here as well. Please handle conversion failures… · Newffmpeg_dec_pcm_to_frame()returns an error code, but the result is ignored. If it fails (e.g.,… · New This relies on the internal layout of libavcodec's private ALACContext (priv_data) to read… · New This relies on the internal layout of libavcodec's private ALACContext (priv_data) to read… · Newav_log_set_level()changes a global libav* logging level, which can affect other decoder/encoder… · New These comments say encode is provided viaffmpeg_dec, but the encode path is implemented under… · New
Review effort: Lite
lgirdwood
commented
Nov 14, 2026
Update get_codec_info() comments for FLAC, ALAC, SBC/mSBC, G.722, and aptX compress capture entries to reference ffmpeg_enc instead of ffmpeg_dec. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Consolidate sample-format conversion to Q1.31 using sign_extend_s24(), Q_SHIFT(), and Q_CONVERT_QTOD() via sof_pcm_sample_to_q31(), and remove the duplicate S24/S32-to-S16 conversion helpers from ffmpeg-encode.c. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
- Add configure_avctx() and is_trailing_eof() hooks to struct ffmpeg_dec_codec_ops and move G.722/aptX configuration out of core ffmpeg_dec-ffmpeg.c. - Always stage unparsed payloads into ff->pktbuf and zero-pad AV_INPUT_BUFFER_PADDING_SIZE even when prev_len == 0. - Preserve and restore av_log_get_level() across unparsed frame decode calls. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
lgirdwood
force-pushed
the
topic/ffmpeg-lossless
branch
from
November 14, 2026 17:17
e3da217 to
10764ee
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The unconditional eight-byte peek stalls valid six-byte raw ALAC frames, preventing decoding and end-of-stream completion; eight bytes should be required only for possible CAF headers or inline ALAC atoms.
1 open issue
9 resolved since last review
Whenprev_len == 0, the code passesindirectly to libavcodec (pkt_data = in) without…cd->in_bufis used for header sniffing (memcmp/alac_read_be32) without first… Thesedrules/FLAC_MAX_BLOCKSIZE/1152/greplaces the macro name everywhere, which can break…av_log_set_level()changes a global libav* logging level, which can affect other decoder/encoder… This relies on the internal layout of libavcodec's private ALACContext (priv_data) to read… This relies on the internal layout of libavcodec's private ALACContext (priv_data) to read…ffmpeg_dec_pcm_to_frame()returns an error code, but the result is ignored. If it fails (e.g.,…ffmpeg_dec_pcm_to_frame()return value is ignored here as well. Please handle conversion failures… These comments say encode is provided viaffmpeg_dec, but the encode path is implemented under…
Review effort: Balanced
- Peek ALAC_HEADER_TAG_SIZE (4 bytes) first into cd->in_buf, requiring 8 bytes only for CAF/'alac' header detection. - Replace container/cookie magic numbers with named ALAC_* defines. - Pin libavcodec version (61.19.101) with _Static_assert and validate gb_buffer/gb_buffer_end bounds in ffmpeg_dec_alac_frame_bytes_consumed(). - Implement configure_avctx() and is_trailing_eof() hooks for ALAC. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
- Restrict FLAC_MAX_BLOCKSIZE sed substitutions in ffmpeg.cmake so the #define FLAC_MAX_BLOCKSIZE identifier is not overwritten. - Check ffmpeg_dec_pcm_to_frame() return values and propagate errors in the FLAC, ALAC, SBC, G.722, and aptX encoders. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
lgirdwood
force-pushed
the
topic/ffmpeg-lossless
branch
from
November 14, 2026 19:09
10764ee to
5321949
Compare
lgirdwood
marked this pull request as ready for review
November 14, 2026 19:48
lgirdwood
requested review from
dbaluta,
kv2019i,
lbetlej,
mmaka1 and
plbossart
as code owners
November 14, 2026 19:48
PR 11427: test resultsRun date: 2026-11-14 20:57 UTC Tested commit: 53219497139d1215adbc8bc3e84e692092eaabbe |
Member
Author
|
CI failure unrelated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Add Phase 1 lossless compress playback and capture codecs to
ffmpeg_decusing native fixed-pointlibavcodecimplementations:CONFIG_FFMPEG_DEC_ALAC,SND_AUDIOCODEC_ALAC):.cafcontainer parser (kukichunk 36-byte ALAC magic cookie extraction anddatachunk framing) and inline 36-byte QuickTime'alac'atom header support.GetBitContextand partial-frame reassembly across LL period boundaries.CONFIG_FFMPEG_ENC_FLAC,SND_AUDIOCODEC_FLAC):libavcodecflacencoder configured with fixed integer LPC predictors (FF_LPC_TYPE_FIXED,compression_level = 1) for deterministic low-MCPS DSP encoding."fLaC"+STREAMINFOmetadata block fromavctx->extradatato produce a self-contained.flacstream.FlacEncodeContextdimensions on a build-tree copy offlacenc.c(FLAC_MAX_BLOCKSIZE=1152,rc_sums[1],FLAC_MAX_CHANNELS=2), reducing context allocation 122x from 7.35 MiB to 43.5 KiB.CONFIG_FFMPEG_ENC_ALAC,SND_AUDIOCODEC_ALAC):libavcodecalacencoder configured with fixed LPC prediction (compression_level = 1) and planar S16 input conversion.'alac'magic cookie fromavctx->extradata.SND_AUDIOCODEC_ALACplayback andSND_AUDIOCODEC_FLAC/SND_AUDIOCODEC_ALACcapture inIPC4_SOF_CODEC_INFO.sof-hda-generic-ffmpeg-alac-compr,sof-hda-generic-ffmpeg-flac-enc-compr, andsof-hda-generic-ffmpeg-alac-enc-comprdevelopment topology targets.Hardware Verification (Aphid PTL ACE 3.0 & Spider TGL CAVS 2.5)
Verified end-to-end on both Aphid (
ptl) and Spider (tgl):.cafplayback (comprC0D50,codec_id=15)comprC0D51,codec_id=10) + round-trip playback (comprC0D50)comprC0D51,codec_id=15) + round-trip playback (comprC0D50)